import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export const store = new Vuex.Store({
  state:{
    //设置总线变量
    mode:"vue-vuex",
    counter:0,
    dataArr:['a','b','c']
  },
  getters:{
    //获取总线变量
    getMode(state){
      return state.mode;
    }
  },
  mutations:{
    //修改总线变量
    mut_changeMode(state,payload){
      console.log(payload);
    }

  },
  actions:{
    //总线变量的异步分发
    act_changeMode({ commit },payload){
      // console.log("commit:",commit);
      commit("mut_changeMode",payload);
    }

  }
})
